/**
 * 
 */
package unitTests;


import pieces.*;
import mainClasses.*;
import junit.framework.TestCase;

/**
 * @author jmikhail
 *
 */
public class QueenTest extends TestCase {

	Board testingBoard = new Board();
	
	/**
	 * @param name - Name of the test
	 */
	public QueenTest(String name) {
		super(name);
	}

	
	
	
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#setUp()
	 */
	protected void setUp() throws Exception {
		super.setUp();
	}

	
	
	/* (non-Javadoc)
	 * @see junit.framework.TestCase#tearDown()
	 */
	protected void tearDown() throws Exception {
		super.tearDown();
	}

	
	
	
	/**
	 * Test method for {@link pieces.Queen#movePossible(java.awt.Point)}.
	 */
	public void testMovePossible() {
		Queen WhiteTestingQueen1 = new Queen(1, 1, testingBoard, "White");
		Queen WhiteTestingQueen2 = new Queen(1, 6, testingBoard, "White");

		Queen BlackTestingQueen1 = new Queen(6, 1, testingBoard, "Black");
		Queen BlackTestingQueen2 = new Queen(6, 6, testingBoard, "Black");

		testingBoard.add(WhiteTestingQueen1);
		testingBoard.add(WhiteTestingQueen2);

		testingBoard.add(BlackTestingQueen1);
		testingBoard.add(BlackTestingQueen2);	//Add all the Queens to the board
		
		/*
		 * Testing for the movement of a white Queen
		 */
		assertTrue(WhiteTestingQueen1.movePossible(1,2));	//Upward Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(0,1));	//Left Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(1,0));	//Downward Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(2,1));	//Right Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(0,2));	//Diagonal Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(0,0));	//Diagonal Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(2,0));	//Diagonal Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(2,2));	//Diagonal Movement into an empty block
		
		assertTrue(WhiteTestingQueen1.movePossible(6,1));	//Checks that a white Queen can kill a black piece
		assertFalse(WhiteTestingQueen1.movePossible(1,6));	//Checks that a white Queen can't kill a white piece
		
		assertFalse(WhiteTestingQueen1.movePossible(7,1));	//Checks that a white Queen can't jump over a white piece
		assertFalse(WhiteTestingQueen1.movePossible(1,7));	//Checks that a white Queen can't jump over a black piece
		
		
		/*
		 * Testing for the movement of a black Queen
		 */
		assertTrue(BlackTestingQueen2.movePossible(6,7));	//Upward Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(5,6));	//Left Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(6,5));	//Downward Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(7,6));	//Right Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(5,7));	//Diagonal Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(7,7));	//Diagonal Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(5,5));	//Diagonal Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(7,5));	//Diagonal Movement into an empty block
		
		assertTrue(BlackTestingQueen2.movePossible(1,6));	//Checks that a black Queen can kill a white piece
		assertFalse(BlackTestingQueen2.movePossible(6,1));	//Checks that a black Queen can't kill a black piece
		
		assertFalse(BlackTestingQueen2.movePossible(0,6));	//Checks that a black Queen can't jump over a white piece
		assertFalse(BlackTestingQueen2.movePossible(6,0));	//Checks that a black Queen can't jump over a black piece
	}

	
	
	
	/**
	 * Test method for {@link pieces.Queen#Queen(int, int, mainClasses.Board, java.lang.String)}.
	 */
	public void testQueen() {
		Queen testingQueen1 = new Queen(2,5, testingBoard, "White");
		assertEquals(testingQueen1.getX(), 2);
		assertEquals(testingQueen1.getY(), 5);
		assertTrue(testingQueen1.board.equals(testingBoard));
		assertFalse(testingQueen1.getClass().equals(NullPiece.class));
		assertEquals(testingQueen1.getType(), "  Queen  ");
		assertEquals(testingQueen1.getSide(), "White");
	}

	
	
	
	/**
	 * Test method for {@link pieces.Queen#eightQueenMove(java.awt.Point)}.
	 */
	public void testEightQueenMove() {
		Queen WhiteTestingQueen1 = new Queen(1, 1, testingBoard, "White");
		Queen WhiteTestingQueen2 = new Queen(1, 6, testingBoard, "White");

		Queen BlackTestingQueen1 = new Queen(6, 1, testingBoard, "Black");
		Queen BlackTestingQueen2 = new Queen(6, 6, testingBoard, "Black");

		testingBoard.add(WhiteTestingQueen1);
		testingBoard.add(WhiteTestingQueen2);

		testingBoard.add(BlackTestingQueen1);
		testingBoard.add(BlackTestingQueen2);	//Add all the Queens to the board
		
		/*
		 * Testing for the movement of a white Queen
		 */
		assertTrue(WhiteTestingQueen1.movePossible(1,5));	//Upward Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(0,1));	//Left Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(1,0));	//Downward Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(2,1));	//Right Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(0,2));	//Diagonal Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(0,0));	//Diagonal Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(2,0));	//Diagonal Movement into an empty block
		assertTrue(WhiteTestingQueen1.movePossible(2,2));	//Diagonal Movement into an empty block
		
		
		/*
		 * Testing for the movement of a black Queen
		 */
		assertTrue(BlackTestingQueen2.movePossible(6,7));	//Upward Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(5,6));	//Left Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(6,5));	//Downward Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(7,6));	//Right Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(5,7));	//Diagonal Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(7,7));	//Diagonal Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(5,5));	//Diagonal Movement into an empty block
		assertTrue(BlackTestingQueen2.movePossible(7,5));	//Diagonal Movement into an empty block
		
		}


	

	
	
	
	
	/**
	 * Test method for {@link pieces.Piece#isEnemy(java.awt.Point)}.
	 */
	public void testIsEnemy() {
		Queen WhiteTestingQueen1 = new Queen(1, 1, testingBoard, "White");
		Queen WhiteTestingQueen2 = new Queen(2, 2, testingBoard, "White");
		Queen BlackTestingQueen1 = new Queen(3, 3, testingBoard, "Black");
		Queen BlackTestingQueen2 = new Queen(4, 4, testingBoard, "Black");
		
		testingBoard.add(WhiteTestingQueen1);
		testingBoard.add(WhiteTestingQueen2);
		testingBoard.add(BlackTestingQueen1);
		testingBoard.add(BlackTestingQueen2);
		
		assertTrue(WhiteTestingQueen1.isEnemy(3,3));	//Checks that BlackTestingQueen1 IS an enemy
		assertFalse(WhiteTestingQueen1.isEnemy(2,2));	//Checks that WhiteTestingQueen2 IS NOT an enemy
		assertFalse(WhiteTestingQueen1.isEnemy(7,7));	//Checks that a NullPiece IS NOT an enemy
		
		assertTrue(BlackTestingQueen1.isEnemy(2,2));	//Checks that WhiteTestingQueen2 IS an enemy
		assertFalse(BlackTestingQueen1.isEnemy(4,4));	//Checks that BlackTestingQueen2 IS NOT an enemy
		assertFalse(BlackTestingQueen1.isEnemy(7,7));	//Checks that a NullPiece IS NOT an enemy
	
	}

	
	
	
	
	/**
	 * Test method for {@link pieces.Piece#getPoint()}.
	 */
	public void testGetPoint() {
		
		Queen testingQueen5 = new Queen(3, 3, testingBoard, "White");
		assertTrue(testingQueen5.getX()==3 && testingQueen5.getY()==3);
		assertFalse(testingQueen5.getX()==4 && testingQueen5.getY()==5);
		
		Queen testingQueen6 = new Queen(4, 5, testingBoard, "White");
		assertTrue(testingQueen6.getX()==4 && testingQueen6.getY()==5);
		assertFalse(testingQueen6.getX()==3 && testingQueen6.getY()==3);
	
	}

	
	
	
	
	
	/**
	 * Test method for {@link pieces.Piece#getType()}.
	 */
	public void testGetType() {
		Queen testingQueen4 = new Queen(5, 5, testingBoard, "White");
		
		assertEquals(testingQueen4.getType(), "  Queen  ");

		testingQueen4.setType("RandomType");
		assertEquals(testingQueen4.getType(), "RandomType");
	
	}

	
	
	
	
	/**
	 * Test method for {@link pieces.Piece#getSide()}.
	 */
	public void testGetSide() {
		Queen testingQueen3 = new Queen(6, 6, testingBoard, "White");

		assertEquals(testingQueen3.getSide(), "White");
	
	}

	
	
	
	
	/**
	 * Test method for {@link pieces.Piece#setType(java.lang.String)}.
	 */
	public void testSetType() {
		Queen testingQueen2 = new Queen(5, 5, testingBoard, "White");

		testingQueen2.setType("RandomType");
		assertEquals(testingQueen2.getType(), "RandomType");
	}

	
	
	
	
	/**
	 * Test method for {@link pieces.Piece#isEqual(pieces.Piece)}.
	 */
	public void testIsEqual() {
		Queen testingQueen1 = new Queen(4, 1, testingBoard, "White");
		Queen testingQueen2 = new Queen(4, 1, testingBoard, "White");
		Queen testingQueen3 = new Queen(3, 1, testingBoard, "White");

		
		assertTrue(testingQueen1.isEqual(testingQueen2));
		assertFalse(testingQueen1.isEqual(testingQueen3));
	}

	
	
	

	/**
	 * Test method for {@link pieces.Piece#changePosition(java.awt.Point)}.
	 */
	public void testChangePosition() {
		Queen testingQueen1 = new Queen(3, 7, testingBoard, "White");
		testingQueen1.changePosition(3,2);
		assertEquals(testingQueen1.getX(), 3);
		assertEquals(testingQueen1.getY(), 2);
		
		testingQueen1.changePosition(7,2);
		assertEquals(testingQueen1.getX(), 7);
		assertEquals(testingQueen1.getY(), 2);
	}

}
